package interpreter;

import java.io.BufferedReader;
import java.io.FileReader;

public class ParserBuilder {
    public static String readJsonText(String filePath) throws Exception {
        FileReader fileReader = new FileReader(filePath);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        StringBuilder codeText = new StringBuilder();
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            codeText.append(line);
        }
        return codeText.toString();
    }
    static public Parser produceParser(String filePath) throws Exception {
        String codeText = readJsonText(filePath);
        Lexer lexer = new Lexer(codeText);
        return new Parser(lexer);
    }
}
